import { Service, Inject, Transactional } from "boot/decorator"
import UserDao from "../dao/UserDao"

@Service()
export default class UserService {

  @Inject()
  userDao: UserDao

  // async addUser(userInfo: IUserInfo) {
  //   return await this.userDao.addUser(userInfo)
  // }

  async getUser(id: number) {
    return await this.userDao.getUserById(id)
  }

  // @Transactional()
  async addUser() {
    await this.userDao.addUser()
    await this.addUser2()
    await this.addUser2()
    await this.userDao.addUser()
    return 'success'
  }

  @Transactional()
  async addUser2() {
    await this.userDao.addUser()
  }
}
